<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;

class Role extends Model
{
  use Notifiable;
  protected $table = 'roles';

  // 角色列表
  public static function getList($request)
  {
    $query = self::select('*');
    if (isset($request->status) && $request->status) {
      $query->where('status', $request->status);
    } 
    if (isset($request->sort) && $request->sort) {
      $query->orderBy($request->sort, $request->order);
    } else {
      $query->orderBy('id', 'desc');
    }
    $res = $query->paginate($request->size);
    return $res ? $res->toArray() : [];
  }

  // 角色详情
  public static function getInfo($id) {
    $res = self::select('*')->where('id', $id)->first();
    return $res ? $res->toArray() : [];
  }
}
